<!DOCTYPE html>
<html>
	<head>
	 
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>用户登录</title>
		<link rel="shortcut icon" type="image/x-icon" href="../image/logo.png" />
		<link rel="stylesheet"  type="text/css" href="../layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="../css/login.css" />
	</head>
	<body>
		<div class="head">  
			<div class="logo">
				<img class="logo-img" src="../image/logo.png" />
				<div class="admin"><a href="adminlogin.html">
					<div class="admin-login">
						<img src="../image/管理员.png" />
					</div>

					<p>管理员入口</p>
				</a></div>
			</div>


			 
			
			<div class="login">
				<img src="../image/login02.png" />
			</div>
			
			<div class="login-text">
				 
				<form class="yc-login">
					<ul>
						
						<li class="yc-tel">								 
							<input type="text" name="mtel" id="u_phone" v-model="mtel" placeholder="请输入手机号" @blur="finds()" />
						</li>

						<li class="yc-pwd">
							 
							<input type="password" name="mpwd"  id="u_pwd" v-model="mpwd" placeholder="请输入密码" />
						</li>
						 
						<li class="yc-yanzheng">
							 <div class="jizhumima"> <input id="jizhu" type="checkbox" name="" title="记住密码" lay-skin="primary" /><span> 记住密码</span> </div>
							 <div class="zhuce"> <a class="yc-zhece" href="register.html"   >还没有注册</a></div>
						</li>
						<li>
							<a id="login" class="yc-btn" href="javascript:void(0)" @click="reg">登录</a>
						</li>
						<li class="yc-tishi">
							<input type="radio" checked="checked"/>
							 我已阅读并同意<a href="#">《数码用户服务协议》</a><a href="#">《隐私政策》</a> 
						</li>
						
						  
						 
					</ul>
					
				</form>
			</div>
			
			
		</div>
		
		
		
		
	</body>

	<script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
	<script src="../layui/layui.js"></script>
	<script>







		$(document).ready(function(){
			$("#u_phone").blur(function(){

				let phone = $("#u_phone").val();
				//session里存储   uId
				$.get("../user",{op:"eject",uPhone:phone},function (rs) {
					if(rs !=null){
						$("#u_pwd").val(rs);
					}

				},"json");



			});
		});


		$(document).ready(function(){
			$("#jizhu").change(function(){
				if($(this).is(":checked")) {
					let uphone = $("#u_phone").val();
					let upwd = $("#u_pwd").val();

					//session里存储   uId
					$.get("../user",{op:"remember",uPhone:uphone,uPwd:upwd},function (rs) {


					},"json");


				} else {

					//session里存储   uId
					$.get("../user",{op:"forgot" },function (rs) {



					},"json");
				}
			});
		});



		$("#login").click(function () {


			let u_phone = $("#u_phone").val();
			let u_pwd = $("#u_pwd").val();


			$.ajax({

				url:'../user',
				dataType:'json',

				secureuri:false,
				data:{
					op:'login',u_phone:u_phone,u_pwd:u_pwd
				},
				success:function (rs) {
					if(rs != null){
						getuId(rs.data) ;


						// 弹出加载提示
						var index = layer.load(1, {
							shade: [0.5,'#000'] // 加载提示的样式
						});

						// 模拟1秒后加载完成
						setTimeout(function(){
							layer.close(index); // 关闭加载提示
							// 这里是加载完成后要执行的代码
							window.location.href = 'index.html#'+getuId(rs.data) ;
						}, 1000); // 1000毫秒 = 1秒


					}
					else{
						alert('手机号或密码错误');
					}

				},
				error:function (rs) {
					alert('手机号或密码错误');

				}


			});

			function getuId(arr){

				//session里存储   uId
				$.get("../user",{op:"lg",uId:arr[0].uId},function (rs) {
					localStorage.setItem("uId",arr[0].uId);
					localStorage.setItem("headshotUrl",arr[0].pic);

					if(rs > 0){

						return rs;
					}
				},"json");




			}





		});



	</script>


</html>
